﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using SystemFrameWork;
using System.Reflection;

namespace DAL
{
    public class EnittyDAO
    {
        /// <summary>
        /// sql connection
        /// </summary>
        protected SqlConnection Con
        {
            get
            {
                SqlConnection con = new SqlConnection(ConfigurationHelper.SqlConnectionString);
                return con;
            }
        }

        /// <summary>
        /// Commit the operation
        /// </summary>
        public void CommitUpdate()
        {
            try
            {
                DataContextManager mgr = new DataContextManager();
                mgr.Commit();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        /// <summary>
        /// begin a transaction
        /// </summary>
        /// <returns></returns>
        public void BeginTransaction()
        {
            DataContextManager mgr = new DataContextManager();
            SqlTransaction trans = mgr.BeginTransaction();
        }

        /// <summary>
        /// commit a transaction
        /// </summary>
        public void CommitTransaction()
        {
            DataContextManager mgr = new DataContextManager();
            mgr.CommitTransaction();
        }

        /// <summary>
        /// roll back the transaction
        /// </summary>
        public void RollBackTransaction()
        {
            DataContextManager mgr = new DataContextManager();
            mgr.RollBackTransaction();
        }
    }
}
